<template lang="pug">
	.login-wrap
		.login-icon
			img(src="../../assets/image/login/login-icon.png")
		.login-input
			input-line(placeholder="请输入手机号" type="number" @getValue="getPhone" maxlength="11")
		.login-btn(@click="jumpToNext")
			main-button(text="下一步" :isActive="nextStepPass")
		.login-by-password(@click="goPaswd") 密码登录
		.login-footer 台州市卫生和计划生育委员会 监制
</template>

<script>
import inputLine from '@/components/input-line'
import mainButton from '@/components/main-button'
export default {
	data() {
		return {
			nextStepPassData: false,
			phone: ''
		}
	},
	computed: {
		nextStepPass() {
			return this.nextStepPassData
		}
	},
	onLoad() {
		Object.assign(this.$data, this.$options.data())
	},
	mounted() {},
	onShow() {},
	onPullDownRefresh() {},
	onPageScroll(e) {},
	methods: {
		jumpToNext() {
			let that = this
			if (this.nextStepPassData) {
				this.wx.showLoading({
					title: '加载中'
				})
				this.api.tzApi
					.checkRegister({
						phone: this.phone
					})
					.then(data => {
						this.wx.hideLoading()
						if (data.responseFlag === '1') {
							let state = data.data.state
							if (state === 0 || state === 1) {
								//未注册
								this.$router.push({
									path: '/views/login/register',
									query: {
										phone: that.phone
									}
								})
							} else if (state === 2) {
								this.$router.push({
									path: '/views/login/loginByVerification',
									query: {
										phone: that.phone
									}
								})
							}
						} else {
						}
					})
					.catch(() => {
						this.wx.hideLoading()
					})
			}
		},
		getPhone(text) {
			text = text.toString()
			this.phone = text
			if (text.length === 11) {
				this.nextStepPassData = this.tools.isMobile(text)
			} else {
				this.nextStepPassData = false
			}
		},
		goPaswd() {
			this.$router.push({
				path: '/views/login/loginByPaswd'
			})
		}
	},
	components: {
		inputLine,
		mainButton
	}
}
</script>

<style lang="stylus">
	page
		background-color white!important
	.login-icon
		width 210px
		height 220px
		margin 0 auto
		margin-top 140px
		img
			width 100%
			height 100%
	.login-input
		margin-top 100px
		.placeholderClass
			font-size 36px
			line-height 50px
		input
			font-size 36px!important
			line-height 50px!important
	.login-btn
		width 690px
		height 92px
		margin 80px auto 0
		border-radius 46px
		overflow hidden
	.login-by-password
		margin-top 30px
		text-align center
		font-size 26px
		line-height 36px
		font-weight 400
		color themeColor
	.login-footer
		position fixed
		bottom 38px
		width 100%
		text-align center
		color grayFontColor
		font-size 24px
		line-height 34px
</style>
